from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime

class ProjectBase(BaseModel):
    name: str = Field(..., description="项目名称")
    description: Optional[str] = Field(None, description="项目描述")
    git_repository_url: str = Field(..., description="Git仓库地址")
    git_username: str = Field(..., description="Git用户名")
    git_branch: str = Field(default="main", description="Git分支")
    git_access_token: Optional[str] = Field(None, description="Git访问令牌")
    db_host: Optional[str] = Field(None, description="数据库主机")
    db_port: Optional[int] = Field(None, description="数据库端口")
    db_name: Optional[str] = Field(None, description="数据库名称")
    db_username: Optional[str] = Field(None, description="数据库用户名")
    db_password: Optional[str] = Field(None, description="数据库密码")
    db_schema: Optional[str] = Field(None, description="数据库Schema")
    db_type: Optional[str] = Field(None, description="数据库类型")
    status: str = Field(default="active", description="项目状态")
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None

    class Config:
        orm_mode = True

class ProjectCreate(ProjectBase):
    pass

class ProjectUpdate(ProjectBase):
    name: Optional[str] = None
    git_repository_url: Optional[str] = None
    git_username: Optional[str] = None
    git_branch: Optional[str] = None

class ProjectSettings(BaseModel):
    git_access_token: Optional[str] = None
    db_host: Optional[str] = None
    db_port: Optional[int] = None
    db_name: Optional[str] = None
    db_username: Optional[str] = None
    db_password: Optional[str] = None
    db_schema: Optional[str] = None
    db_type: Optional[str] = None 